<template>
	<view class="content">
		<view class="top" v-if="type==1">
			<image src="../../static/images/addsuccess.png"></image>
			<text>提问成功,邀请大佬来回答</text>
		</view>
		<view class="bottom">
			<view class="title">
				邀请他人回答问题
			</view>
			<view v-for="(item,index) in users" :key="index" class="user" v-if="item.id!=user.id">
				<view class="left">
					<image :src="getRealPath(item.imgUrl)" mode=""></image>
					<text>{{item.nickName}}</text>
				</view>
				<view class="right" @tap="invite(index,item.id)">
					邀请
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import utils from "../../static/js/utils.js"
	import {
			mapState,
			mapMutations
		} from 'vuex';
	export default {
		data() {
			return {
				questionId:0,
				type:0,
				users: []
			}
		},
		computed:{
			...mapState(['user']),
		},
		methods: {
			getRealPath(path) {
				return utils.baseImgUrl + path;
			},
			invite(index,id) {
				let that = this;
				utils.post("question/inviteuser",{
					questionId:this.questionId,
					userId:this.user.id,
					inviteId:id
				},function(data) {
					that.users.splice(index,1);
					utils.successToast("邀请成功");
				})
			}
		},
		onLoad(option) {
			this.type = option.type;
			this.questionId = option.questionId;
			let that = this;
			utils.get("question/getinviteuser",{
				questionId:this.questionId,
				userId:this.user.id
			},function(data) {
				that.users = data;
			})
		}
	}
</script>

<style>
	page {
		background-color: #f6f6f6;
	}

	.content {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.title {
		height: 80upx;
		width: 92%;
		line-height: 80upx;
		font-size: 30upx;
		box-shadow: inset 0px -1px 1px -1px #dcdcdc;
	}

	.top {
		width: 100%;
		background-color: #ffffff;
		display: flex;
		align-items: center;
		flex-direction: column;
		height: 400upx;
		justify-content: center;
	}

	.top image {
		height: 200upx;
		width: 200upx;
	}

	.top text {
		font-size: 28upx;
		color: #999999;
		margin-top: 30upx;
	}

	.bottom {
		width: 100%;
		margin-top: 40upx;
		background-color: #ffffff;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.bottom .user {
		width: 92%;
		height: 100upx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.left {
		display: flex;
		flex-direction: row;
		height: 100upx;
		align-items: center;
	}

	.left image {
		width: 66upx;
		height: 66upx;
		border-radius: 66upx;

	}

	.left text {
		font-size: 28upx;
		margin-left: 20upx;
	}

	.right {
		width: 120upx;
		height: 50upx;
		font-size: 24upx;
		background-color: #FF4040;
		border-radius: 10upx;
		color: #ffffff;
		text-align: center;
		line-height: 50upx;

	}
</style>
